package org.particlethink.request;

import io.swagger.v3.oas.annotations.media.Schema;
import org.particlethink.model.BatchPlan;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

public class BatchPlanRequest {
    @Schema(description = "项目id")
    private int projectId;//项目id
    @Schema(description = "总计划id")
    private int masterPlanId;//总计划id
    @Schema(description = "最晚进场时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deadlineAt;//最晚进场时间

    @Schema(description = "备注")
    private String remark;//备注
    @Schema(description = "附件")
    private String attachment;//附件
    @Schema(description = "附件名")
    private String attachmentName;//附件
    @Schema(description = "是否提交")
    private boolean isSubmit;


    public List<PlanMaterialRequest> getPlanMaterialRequests() {
        return planMaterialRequests;
    }

    private List<PlanMaterialRequest> planMaterialRequests;

    public int expectNum() {
        return planMaterialRequests.stream()
                .mapToInt(PlanMaterialRequest::getExpectNum)
                .sum();
    }


    public void updateBatchPlan(BatchPlan masterPlan) {
        masterPlan.setDeadlineAt(deadlineAt);
        masterPlan.setRemark(remark);
        masterPlan.setAttachment(attachment);
        masterPlan.setAttachmentName(attachmentName);
    }


//    public BatchPlan toBatchPlan(int creatorId) {
//        return new BatchPlan(
//                projectId,
//                masterPlanId,
//                deadlineAt,
//                remark,
//                creatorId,
//                attachment
//        );
//    }

    public int getProjectId() {
        return projectId;
    }

    public void setProjectId(int projectId) {
        this.projectId = projectId;
    }

    public int getMasterPlanId() {
        return masterPlanId;
    }

    public void setMasterPlanId(int masterPlanId) {
        this.masterPlanId = masterPlanId;
    }

    public Date getDeadlineAt() {
        return deadlineAt;
    }

    public void setDeadlineAt(Date deadlineAt) {
        this.deadlineAt = deadlineAt;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getAttachment() {
        return attachment;
    }

    public void setAttachment(String attachment) {
        this.attachment = attachment;
    }

    public void setPlanMaterialRequests(List<PlanMaterialRequest> planMaterialRequests) {
        this.planMaterialRequests = planMaterialRequests;
    }

    public boolean isSubmit() {
        return isSubmit;
    }

    public void setIsSubmit(boolean submit) {
        isSubmit = submit;
    }

    public String getAttachmentName() {
        return attachmentName;
    }

    public void setAttachmentName(String attachmentName) {
        this.attachmentName = attachmentName;
    }

    public void setSubmit(boolean submit) {
        isSubmit = submit;
    }
}
